/*
Copyright (C) 2009-2010 Xanadu Development Team

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2
of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

#pragma once

#include "../scripting/scriptarray.h"

using namespace stdext;

class CScriptArray;
class Player;
class Packet;

class PlayerNPC {
private:
	int npcid;
	Player* player;
	string text;
	int state;
	int selected;
	bool cend;
	int getnum;
	int saveInt;
	int questid;
	string gettext;
	hash_map <string, int> vars;
public:
	PlayerNPC(int npcid, Player* player, int questid = 0);
	~PlayerNPC();
	void addText(string &atext){
		text += atext;
	}
	Packet npcPacket(char type);
	void sendSimple();
	void sendYesNo();
	void sendNext();
	void sendBackNext();
	void sendBackOK();
	void sendOK();
	void sendAcceptDecline();
	void sendGetText();
	void sendGetNumber(int def, int min, int max);
	void sendStyle(CScriptArray* styles);
	int getQuestID(){
		return questid;
	}
	void setState(int state){
		this->state = state;
	}
	int getState(){
		return state;
	}
	int getSelected(){
		return selected;
	}
	void setSelected(int selected){
		this->selected = selected;
	}
	void setGetNumber(int number){
		this->getnum = number;
	}
	int getNumber(){
		return getnum;
	}
	void setGetSaveInt(int num){
		this->saveInt = num;
	}
	int getSaveInt(){
		return saveInt;
	}
	void setGetText(string &text){
		gettext = text;
	}
	string getText(){
		return gettext;
	}
	void end(){
		cend = true;
	}
	bool isEnd(){
		return cend;
	}
	int getNpcID(){
		return npcid;
	}
	Player* getPlayer(){ // to be removed
		return player;
	}
	void setStyle(int id);
	void setVariable(string &name, int val){
		vars[name] = val;
	}
	int getVariable(string &name){
		if(vars.find(name) == vars.end())
			return 0;
		else
			return vars[name];
	}
	void addQuest(short questid);
	void endQuest(short questid);
	void createGuild();
	void changeGuildEmblem();
	void disbandGuild();
	void increaseGuildCapacity();

	static const int normal = 0x00;
	static const int yesNo = 0x01;
	static const int get_Text = 0x02;
	static const int get_Number = 0x03;
	static const int simple = 0x04;
	static const int style = 0x07;
	static const int acceptDecline = 0x0c;
};
